home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / C-D / ChangeObjectLayer.cpt / ChangeObjectLayer / card_2949.txt < prev    next >
Text File  |  1989-04-13  |  16KB  |  548 lines

  1. -- card: 2949 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 2599
  5. -- name: 
  6. ----- HyperTalk script -----
  7. --WARNING!!! DON'T USE THIS SCRIPT. IT IS MODIFIED FOR THE DEMO.
  8. --USE THE VERSION IN THE BACKGROUND SCRIPT INSTEAD!
  9.  
  10. on setLayer
  11.   global objectNumber,objectType,optionState
  12.   put the optionKey into optionState
  13.   put theLayer() into doMenuWhich
  14.   lock screen
  15.   set lockMessages to true
  16.   if objectType = "button" then choose btn tool else choose fld tool
  17.   select the target
  18.   repeat until the number of the target = objectNumber
  19.     set cursor to busy
  20.     if doMenuWhich < 0 then doMenu "Send Farther"
  21.     if doMenuWhich > 0 then doMenu "Bring Closer"
  22.     if doMenuWhich = 0 then exit repeat
  23.   end repeat
  24.   beep
  25.   set cursor to 4
  26.   choose browse tool
  27.   unlock screen
  28.   set lockMessages to false
  29.   put empty into objectNumber
  30.   put empty into objectType
  31.   put empty into optionState
  32. end setLayer
  33.  
  34. function theLayer
  35. global objectNumber,objectType,optionState
  36. if the name of the target contains "field" then
  37.   put "field" into objectType
  38. else
  39.   put "button" into objectType
  40. end if
  41. if the name of the target contains "bkgnd" then
  42.   put "bkgnd" into objectClass
  43. else
  44.   put "card" into objectClass
  45. end if
  46. put the number of the target into fromThis
  47. if objectType = "button" then
  48.   if the name of the target contains "bkgnd" then
  49.     put the number of last bg btn into theRange
  50.   else
  51.     put the number of last btn into theRange
  52.   end if
  53. else
  54.   if objectType = "field" then
  55.     if the name of the target contains "card" then
  56.       put the number of last cd field into theRange
  57.     else
  58.       put the number of last field into theRange
  59.     end if
  60.   end if
  61. end if
  62. ask "Set " & objectClass &&objectType && fromThis && "to what number? (1-6)"
  63. if it is empty then exit to HyperCard
  64. set cursor to 4
  65. put it into objectNumber
  66. if optionState is up then
  67.   if objectNumber > 6 or objectNumber < 1 then
  68.     answer "Sorry!  ‚Äú" &objectNumber & "‚Äù is not a valid " & objectType &&"number."
  69.     exit to HyperCard
  70.   else
  71.   end if
  72. end if
  73. return objectNumber - fromThis
  74. end theLayer
  75.  
  76. --WARNING!!! DON'T USE THIS SCRIPT. IT IS MODIFIED FOR THE DEMO.
  77. --USE THE VERSION IN THE BACKGROUND SCRIPT INSTEAD!
  78.  
  79.  
  80.  
  81. -- part 1 (button)
  82. -- low flags: 00
  83. -- high flags: 8004
  84. -- rect: left=18 top=78 right=195 bottom=248
  85. -- title width / last selected line: 0
  86. -- icon id / first selected line: 27056 / 27056
  87. -- text alignment: 1
  88. -- font id: 3
  89. -- text size: 12
  90. -- style flags: 0
  91. -- line height: 16
  92. -- part name: Card Button 1
  93. ----- HyperTalk script -----
  94. on mouseUp
  95.   setlayer
  96.   lock screen
  97.   repeat with i = 1 to 6
  98.     set the name of cd btn i to "Card Button " & i
  99.   end repeat
  100.   unlock screen
  101. end mouseUp
  102.  
  103.  
  104.  
  105. -- part 22 (button)
  106. -- low flags: 00
  107. -- high flags: 8004
  108. -- rect: left=24 top=80 right=96 bottom=241
  109. -- title width / last selected line: 0
  110. -- icon id / first selected line: 0 / 0
  111. -- text alignment: 1
  112. -- font id: 0
  113. -- text size: 12
  114. -- style flags: 0
  115. -- line height: 16
  116. -- part name: Card Button 2
  117. ----- HyperTalk script -----
  118. on mouseUp
  119.   setlayer
  120.   lock screen
  121.   repeat with i = 1 to 6
  122.     set the name of cd btn i to "Card Button " & i
  123.   end repeat
  124.   unlock screen
  125. end mouseUp
  126.  
  127.  
  128.  
  129. -- part 23 (button)
  130. -- low flags: 00
  131. -- high flags: 8004
  132. -- rect: left=30 top=93 right=109 bottom=235
  133. -- title width / last selected line: 0
  134. -- icon id / first selected line: 0 / 0
  135. -- text alignment: 1
  136. -- font id: 0
  137. -- text size: 12
  138. -- style flags: 0
  139. -- line height: 16
  140. -- part name: Card Button 3
  141. ----- HyperTalk script -----
  142. on mouseUp
  143.   setlayer
  144.   lock screen
  145.   repeat with i = 1 to 6
  146.     set the name of cd btn i to "Card Button " & i
  147.   end repeat
  148.   unlock screen
  149. end mouseUp
  150.  
  151.  
  152.  
  153. -- part 24 (button)
  154. -- low flags: 00
  155. -- high flags: 8004
  156. -- rect: left=36 top=106 right=122 bottom=228
  157. -- title width / last selected line: 0
  158. -- icon id / first selected line: 0 / 0
  159. -- text alignment: 1
  160. -- font id: 0
  161. -- text size: 12
  162. -- style flags: 0
  163. -- line height: 16
  164. -- part name: Card Button 4
  165. ----- HyperTalk script -----
  166. on mouseUp
  167.   setlayer
  168.   lock screen
  169.   repeat with i = 1 to 6
  170.     set the name of cd btn i to "Card Button " & i
  171.   end repeat
  172.   unlock screen
  173. end mouseUp
  174.  
  175.  
  176.  
  177. -- part 26 (button)
  178. -- low flags: 00
  179. -- high flags: 8004
  180. -- rect: left=49 top=132 right=148 bottom=215
  181. -- title width / last selected line: 0
  182. -- icon id / first selected line: 0 / 0
  183. -- text alignment: 1
  184. -- font id: 0
  185. -- text size: 12
  186. -- style flags: 0
  187. -- line height: 16
  188. -- part name: Card Button 5
  189. ----- HyperTalk script -----
  190. on mouseUp
  191.   setlayer
  192.   lock screen
  193.   repeat with i = 1 to 6
  194.     set the name of cd btn i to "Card Button " & i
  195.   end repeat
  196.   unlock screen
  197. end mouseUp
  198.  
  199.  
  200.  
  201. -- part 25 (button)
  202. -- low flags: 00
  203. -- high flags: 8004
  204. -- rect: left=42 top=119 right=135 bottom=222
  205. -- title width / last selected line: 0
  206. -- icon id / first selected line: 0 / 0
  207. -- text alignment: 1
  208. -- font id: 0
  209. -- text size: 12
  210. -- style flags: 0
  211. -- line height: 16
  212. -- part name: Card Button 6
  213. ----- HyperTalk script -----
  214. on mouseUp
  215.   setlayer
  216.   lock screen
  217.   repeat with i = 1 to 6
  218.     set the name of cd btn i to "Card Button " & i
  219.   end repeat
  220.   unlock screen
  221. end mouseUp
  222.  
  223.  
  224.  
  225. -- part 14 (button)
  226. -- low flags: 00
  227. -- high flags: 2000
  228. -- rect: left=4 top=23 right=62 bottom=44
  229. -- title width / last selected line: 0
  230. -- icon id / first selected line: 20098 / 20098
  231. -- text alignment: 1
  232. -- font id: 0
  233. -- text size: 12
  234. -- style flags: 0
  235. -- line height: 16
  236. -- part name: Card Button 6
  237. ----- HyperTalk script -----
  238. on mouseUp
  239.   go home
  240. end mouseUp
  241.  
  242.  
  243.  
  244. -- part 27 (field)
  245. -- low flags: 01
  246. -- high flags: 0004
  247. -- rect: left=263 top=89 right=187 bottom=473
  248. -- title width / last selected line: 0
  249. -- icon id / first selected line: 0 / 0
  250. -- text alignment: 0
  251. -- font id: 4
  252. -- text size: 9
  253. -- style flags: 0
  254. -- line height: 12
  255. -- part name: 
  256. ----- HyperTalk script -----
  257. on mouseUp
  258.   setLayer
  259.   repeat with i = 1 to 6
  260.     put "Card Field " &the number of cd fld i into line 1 of cd field i
  261.   end repeat
  262. end mouseUp
  263.  
  264.  
  265.  
  266. -- part 28 (field)
  267. -- low flags: 01
  268. -- high flags: 0004
  269. -- rect: left=273 top=100 right=178 bottom=462
  270. -- title width / last selected line: 0
  271. -- icon id / first selected line: 0 / 0
  272. -- text alignment: 0
  273. -- font id: 4
  274. -- text size: 9
  275. -- style flags: 0
  276. -- line height: 12
  277. -- part name: 
  278. ----- HyperTalk script -----
  279. on mouseUp
  280.   setLayer
  281.   repeat with i = 1 to 6
  282.     put "Card Field " &the number of cd fld i into line 1 of cd field i
  283.   end repeat
  284. end mouseUp
  285.  
  286.  
  287.  
  288. -- part 29 (field)
  289. -- low flags: 01
  290. -- high flags: 0004
  291. -- rect: left=283 top=111 right=169 bottom=451
  292. -- title width / last selected line: 0
  293. -- icon id / first selected line: 0 / 0
  294. -- text alignment: 0
  295. -- font id: 4
  296. -- text size: 9
  297. -- style flags: 0
  298. -- line height: 12
  299. -- part name: 
  300. ----- HyperTalk script -----
  301. on mouseUp
  302.   setLayer
  303.   repeat with i = 1 to 6
  304.     put "Card Field " &the number of cd fld i into line 1 of cd field i
  305.   end repeat
  306. end mouseUp
  307.  
  308.  
  309.  
  310. -- part 30 (field)
  311. -- low flags: 01
  312. -- high flags: 0004
  313. -- rect: left=293 top=122 right=160 bottom=441
  314. -- title width / last selected line: 0
  315. -- icon id / first selected line: 0 / 0
  316. -- text alignment: 0
  317. -- font id: 4
  318. -- text size: 9
  319. -- style flags: 0
  320. -- line height: 12
  321. -- part name: 
  322. ----- HyperTalk script -----
  323. on mouseUp
  324.   setLayer
  325.   repeat with i = 1 to 6
  326.     put "Card Field " &the number of cd fld i into line 1 of cd field i
  327.   end repeat
  328. end mouseUp
  329.  
  330.  
  331.  
  332. -- part 31 (field)
  333. -- low flags: 01
  334. -- high flags: 0004
  335. -- rect: left=303 top=133 right=151 bottom=431
  336. -- title width / last selected line: 0
  337. -- icon id / first selected line: 0 / 0
  338. -- text alignment: 0
  339. -- font id: 4
  340. -- text size: 9
  341. -- style flags: 0
  342. -- line height: 12
  343. -- part name: 
  344. ----- HyperTalk script -----
  345. on mouseUp
  346.   setLayer
  347.   repeat with i = 1 to 6
  348.     put "Card Field " &the number of cd fld i into line 1 of cd field i
  349.   end repeat
  350. end mouseUp
  351.  
  352.  
  353.  
  354. -- part 12 (field)
  355. -- low flags: 01
  356. -- high flags: 4004
  357. -- rect: left=253 top=78 right=196 bottom=484
  358. -- title width / last selected line: 0
  359. -- icon id / first selected line: 0 / 0
  360. -- text alignment: 0
  361. -- font id: 4
  362. -- text size: 9
  363. -- style flags: 0
  364. -- line height: 12
  365. -- part name: 
  366. ----- HyperTalk script -----
  367. on mouseUp
  368.   setLayer
  369.   if the number of me = 6 then
  370.     put "Change me to Card Field 1!" into line 5 of me
  371.     set the showlines of me to true
  372.   else
  373.     put empty into line 5 of me
  374.     set the showlines of me to false
  375.   end if
  376.   repeat with i = 1 to 6
  377.     put "Card Field " &the number of cd fld i into line 1 of cd field i
  378.   end repeat
  379. end mouseUp
  380.  
  381.  
  382.  
  383. -- part 32 (button)
  384. -- low flags: 00
  385. -- high flags: 2000
  386. -- rect: left=486 top=66 right=90 bottom=511
  387. -- title width / last selected line: 0
  388. -- icon id / first selected line: 2478 / 2478
  389. -- text alignment: 1
  390. -- font id: 0
  391. -- text size: 12
  392. -- style flags: 0
  393. -- line height: 16
  394. -- part name: New Button
  395. ----- HyperTalk script -----
  396. on mouseUp
  397.   set the visible of cd fld about to not the visible of cd fld about
  398. end mouseUp
  399.  
  400.  
  401.  
  402. -- part 13 (button)
  403. -- low flags: 00
  404. -- high flags: A002
  405. -- rect: left=175 top=57 right=72 bottom=320
  406. -- title width / last selected line: 0
  407. -- icon id / first selected line: 0 / 0
  408. -- text alignment: 1
  409. -- font id: 3
  410. -- text size: 9
  411. -- style flags: 16640
  412. -- line height: 12
  413. -- part name: Show Me The Script
  414. ----- HyperTalk script -----
  415. on mouseUp
  416.   --setlayer
  417.   edit script of background
  418. end mouseUp
  419.  
  420.  
  421.  
  422. -- part 33 (field)
  423. -- low flags: 81
  424. -- high flags: 2007
  425. -- rect: left=70 top=69 right=338 bottom=429
  426. -- title width / last selected line: 0
  427. -- icon id / first selected line: 0 / 0
  428. -- text alignment: 0
  429. -- font id: 2
  430. -- text size: 10
  431. -- style flags: 0
  432. -- line height: 13
  433. -- part name: about
  434. ----- HyperTalk script -----
  435. on mouseUp
  436.   hide me
  437.   set the scroll of me to 0
  438. end mouseUp
  439.  
  440.  
  441. -- part contents for card part 31
  442. ----- text -----
  443. Card Field 5
  444.  
  445. -- part contents for card part 12
  446. ----- text -----
  447. Card Field 6
  448.  
  449.  
  450.  
  451. Change me to Card Field 1!
  452.  
  453. -- part contents for card part 27
  454. ----- text -----
  455. Card Field 1
  456.  
  457. -- part contents for card part 28
  458. ----- text -----
  459. Card Field 2
  460.  
  461. -- part contents for card part 29
  462. ----- text -----
  463. Card Field 3
  464.  
  465. -- part contents for card part 30
  466. ----- text -----
  467. Card Field 4
  468.  
  469. -- part contents for background part 7
  470. ----- text -----
  471. Background Field 6
  472.  
  473.  
  474.  
  475. Change me to Background Field 1!
  476.  
  477. -- part contents for background part 18
  478. ----- text -----
  479. Background Field 1
  480.  
  481. -- part contents for background part 21
  482. ----- text -----
  483. Background Field 2
  484.  
  485. -- part contents for background part 22
  486. ----- text -----
  487. Background Field 3
  488.  
  489. -- part contents for background part 23
  490. ----- text -----
  491. Background Field 4
  492.  
  493. -- part contents for background part 24
  494. ----- text -----
  495. Background Field 5
  496.  
  497. -- part contents for card part 33
  498. ----- text -----
  499. About "ChangeObjectLayer" 1.0...
  500.  
  501. ‚Ä¢You've heard of ShareWare and FreeWare!  I now introduce TradeWare!!!
  502.  
  503. This stack is TradeWare.  If you find it useful, send me an 800K floppy packed with ShareWare and FreeWare goodies; I am especially interested in HyperCard development tools and utilities (such as XCMD/XFCNs, etc.‚ÄîI already have the Developer Stack 1.2, Thank You), and system tools and utilities (INITs and CDEVs, etc).  In return, I will send your disk back to you with ShareWare and FreeWare goodies from my own collection.  No sound stacks, please‚Äîthey're too obnoxious, and wasteful of disk space and memory.
  504.  
  505. Please send neat (and/or useful) stuff to:
  506. Dean Wette
  507. 921 DeMun Avenue 2N
  508. Clayton, MO  63105
  509. 314-863-4944                                                       scroll for more...
  510.  
  511. EMail messages, complaints, suggestions, etc to me at:
  512. CIS  72317,2034
  513.  
  514. Remember, when TradeWare becomes rampant throughout the MacCommunity, you heard about it first in this stack!!!
  515.  
  516. ‚Ä¢Now...finally...about ChangeObjectLayer...
  517.  
  518. While developing a stack containing numerous modal popup dialogs, fields, and buttons, I found myself constantly going to the "Objects" menu for the "Send Farther" and "Bring Closer" commands in order to move objects (buttons and fields) through different card and background layers.  In some cases I wanted to obscure other objects, and in other cases I wanted to prevent objects from being obscured.  Well, anyway, when you have 20 or more each of background and card buttons and fields, this menu selection (or its command key equivalent) business to change object layers can become quite tedious and boring.  
  519.  
  520. Therefore, I developed "ChangeObjectLayer" to automate  and speed-up the process of moving objects' through different layers.  "ChangeObjectLayer" works with both card and background buttons and fields.  Try it out!  On this card are six each of card and background buttons and fields.  See the effect of changing a card/background  button/field from 6 to 1 and vice versa.
  521.  
  522. ‚Ä¢To install "ChangeObjectLayer" do the following:
  523. 1) Click on the "Show Me The Script" button.
  524. 2) Copy the handler "setLayer" and the function "theLayer." 
  525. 3) Paste them both into a card, background, or stack script.  The best place for the "ChangeObjectLayer" scripts is in the stack script of your Home stack, thus making the script available in all stacks.
  526.  
  527. ‚Ä¢To invoke "ChangeObjectLayer" do the following:
  528. 1) Open the script editing window of the object (button or field) you want to change.
  529. 2a) If the object contains a script then add "setLayer" (with-out the quotes) as the second line of the objects script‚Äîthe line following "on mouseUp."   The part of the script following "setLayer" will be disabled until you remove the call to "setLayer."  
  530. 2b) If the object does not already have a script then type the following script in the script editing window:
  531.  
  532. on mouseUp
  533.     setLayer
  534. end mouseUp
  535.  
  536. 3) Click "OK" to close the editing window and then click on the object (make sure the browse tool is selected).  Note: if the object is a field, then the lockText property must be set to true (i.e. lock the field) for "ChangeObjectLayer" to work.
  537. 4) You will be prompted to specify the number to which the object will be set.  The prompt will indicate the valid range (e.g. "1-6" - you can't set a card button to 'card button 7' if there are only 6 card buttons).  Enter a valid number, click "OK", and wait.  "ChangeObjectLayer" will beep when it's finished with its task.
  538. 5) Remove the "setLayer" line from the object script to reenable any original object script.  If the "setLayer" call is the second line of the object's script, it will be removed for you.
  539.  
  540. •Notes:
  541. The "setLayer" handler concludes with an "exit to HyperCard" command so if you call it from an existing handler in a button or field, any script folowing the call will not execute until you remove the "setLayer" line of your object script.
  542.  
  543. Sometimes, when an object is set to its highest or lowest number it may still obscure‚Äîor be obscured‚Äîby an object of its unlike type (field/button or vice versa).  To remedy this, you may need to invoke "Send Farther" or "Bring Closer" additional times (i.e. use "Bring Closer" when an object is at its highest number already, or "Send Farther" when it is at its lowest number).  This can be accomplished with "ChangeObjectLayer".  If you hold down the optionkey while invoking the "setLayer" handler from an object, you can enter an invalid object number (such as 0 or 1,000,000).  This will cause "ChangeObjectLayer" to invoke the "Send Farther" or "Bring Closer" menu commands forever.  Press Command-. (period) to stop the repeated execution, and press Command-Tab to select the browse tool.  The "setLayer" handler can be invoked once again in similar manner if necessary.
  544.  
  545. ‚Ä¢Well, that's about it for "ChangeObjectLayer" 1.0.  I wrote and tested it on Friday, July, 29, 1988.  If you find any bugs or have suggestions for improvements please let me know.  Don't forget the TradeWare goodies!
  546.  
  547. Dean Wette [72317,2034]
  548.